<template>
  <div class="app-container">
    <el-tabs type="border-card" @tab-click="tabClick" v-model="type">
      <el-tab-pane name="rule1" label="电影定价规则">
        <Form
          ref="formRef"
          :colLayout="colLayout"
          :labelWidth="labelWidth"
          v-model:formData="info"
          :formItems="formItems"
          :formDataRules="formDataRules"
        >
        </Form>
        <!-- v-hasPermi="['api:v1:changeMoviesDefaultCommission']" -->
        <div style="width: 40vw; margin-left: 150px">
          <el-button @click="submit" type="success" icon="Top">提交</el-button>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
// import { propList, formItems, dialogConfig } from "./config";
import {
  getMoviesDefaultCommission,
  changeMoviesDefaultCommission,
} from "@/api/platform/moviesOrder";
export default {
  name: "platformmoviesSetindex",
  data() {
    return {
      type: "rule1",
      info: {
        movies_commision_rate: 0,
      },
      colLayout: {
        span: 24,
      },
      labelWidth: "220px",
      formDataRules: {
        movies_commision_rate: [
          { required: true, message: "请输入", trigger: "blur" },
        ],
      },
      formItems: [
        {
          field: "movies_commision_rate",
          prop: "movies_commision_rate",
          label: "电影定价百分比（单位%）：",
          placeholder: "电影定价百分比，单位（%）",
          type: "input",
          // width: "150px",
        },
      ],
      form2: {},
      rules2: {
        commision_type: [
          { required: true, message: "请选择计算方式", trigger: "blur" },
        ],
        commision_rate1: [
          { required: true, message: "请输入直属比例或佣金", trigger: "blur" },
        ],
        commision_rate2: [
          { required: true, message: "请输入间接比例或佣金", trigger: "blur" },
        ],
      },
    };
  },
  computed: {},
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    init() {
      this.getInfo();
    },
    async getInfo() {
      const { data } = await getMoviesDefaultCommission();
      this.info = data;
      console.log(data);
    },
    tabClick(tab, event) {
      if (this.type == "rule2") {
        this.getDefaultCommision();
      }
      if (this.type == "rule1") {
        this.getInfo();
      }
    },
    // getDefaultCommision() {
    //   getDefaultCommisionRule().then((response) => {
    //     this.form2 = response.data;
    //   });
    // },
    // updateDefaultCommision() {
    //   this.$refs["form2"].validate((valid) => {
    //     if (valid) {
    //       updateDefaultCommisionRule(this.form2).then((response) => {
    //         this.$modal.msgSuccess("修改成功");
    //         this.getDefaultCommision();
    //       });
    //     }
    //   });
    // },
    submit() {
      console.log("submit");
      this.$refs.formRef.validate(async (valid) => {
        if (valid) {
          console.log(this.info);
          await changeMoviesDefaultCommission(this.info);
          this.$message.success("修改成功");
          this.getInfo();
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
